import org.atmosphere.config.managed.Decoder;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;

/**
 * Created by alex on 15-1-13.
 */
public class JacksonDecoder implements Decoder<String, Message> {
    
    private final ObjectMapper mapper = new ObjectMapper();
    
    @Override
    public Message decode(String s) {
        try {
            return mapper.readValue(s, Message.class);

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
